package cn.auction.dao.impl;

import cn.auction.dao.Iuser;
import cn.auction.entity.AuctionUser;
import my.framework.dao.CommonDao;

import java.sql.SQLException;
import java.util.List;


public class IuseImpl implements Iuser {
    CommonDao dao=new CommonDao();
    @Override
    public void  insert(AuctionUser auctionUser) throws SQLException {
        String sql="insert into auctionuser (userName,userPassword,userCardNo,userTel,userAddress,userPostNumber,userIsAdmin,userQuestion,userAnswer) values(#{userName},#{userPassword},#{userCardNo},#{userTel},#{userAddress},#{userPostNumber},#{userIsAdmin},#{userQuestion},#{userAnswer})";
        dao.executeUpdate(sql,auctionUser);
    }

    @Override
    public AuctionUser UserLogin(String userName, String userPassWord,boolean isAdmin) throws SQLException {
        String sql="select * from auctionuser where userName=? and userPassword=? and userIsAdmin=? ";
        List<AuctionUser> list=dao.executeQuery(AuctionUser.class,sql,new Object[]{userName,userPassWord,isAdmin});
        if(list==null||list.size()==0 ){
            return null;
        }else{
            return list.get(0);
        }
    }
}
